package test1;

import java.util.Arrays;

public class Test2 {
    public static void main(String[] args) {
        int[] nums = new int[]{1, 5, 2, 5, 2, 5, 3, 4, 8, 9};
        int[] arr = insert_sort(nums);
        for (int i : arr) {
            System.out.print(i + " ");
        }
    }

    private static int[] insert_sort(int[] nums) {
        int[] arr = Arrays.copyOf(nums, nums.length);
        for (int i = 0; i < arr.length - 1; i++) {
            int j = i;
            int tmp = arr[j + 1];
            while (j > 0 && tmp < arr[j]) {
                arr[j + 1] = arr[j];
                j--;
            }
            arr[j + 1] = tmp;
        }
        return arr;
    }
}
